// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "WorldMath.h"

/**
 * Iterate through the points on the spiral.
 * Reference: https://github.com/DLR-TS/sumo/blob/master/src/netimport/NIImporter_OpenDrive.cpp
 */
class FWorldSpiralIterator
{
public:

	FWorldSpiralIterator();
	FWorldSpiralIterator(double curvStart, double curvEnd, double length, double res);

	bool HasNext() const;
	void Next();
	void Reset(double curvStart, double curvEnd, double length, double res);

	glm::dvec3 Sample();

	bool IsDegenerate() const;
	double S() const;

private:

	double _curvStart;
	double _curvEnd;
	double _length;
	double _res;

	double _cDot;
	bool _degenerate;
	double _sStart;
	double _sEnd;
	double _tStart;
	glm::dmat3x3 _align;
	double _s;
	double _x;
	double _y;
	double _t;
	bool _itEnd;

};
